#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDebug>
#include <QMessageBox>
loginDialog::loginDialog(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::loginDialog)
{
    ui->setupUi(this);
    connect(ui->m_button,SIGNAL(accepted(void)),this,SLOT(onAccepted()));
    connect(ui->m_button,SIGNAL(rejected(void)),this,SLOT(onRejected()));
}

void loginDialog::onAccepted(void){
    if(ui->user->text() == "ls" && ui->password->text() == "123456"){
        qDebug()<<"登陆成功";
        close();
    }else{
        QMessageBox msgBox(QMessageBox::Critical,
                    "Error",
                    "用户名或密码输入错误",
                    QMessageBox::Ok,
                    this);//父窗口
        msgBox.exec();
    }
}
void loginDialog::onRejected(void){
    QMessageBox qmb(QMessageBox::Question,"quit","是否退出",QMessageBox::Yes|QMessageBox::No,this);
    if(qmb.exec()==QMessageBox::Yes){
        close();
    }
}


loginDialog::~loginDialog()
{
    delete ui;
}
